<?php
/* @var $this UserController */
/* @var $model User */
/* @var $form CActiveForm */
?>

<div class="form">

	<?php $form=$this->beginWidget('CActiveForm', array(
		'id'=>'user-form',
		'enableAjaxValidation'=>false,
		)); ?>

		<p class="note">Fields with <span class="required">*</span> are required.</p>

		<?php echo $form->errorSummary($model); ?>

		<div class="row">
			<?php echo $form->labelEx($model,'username'); ?>
			<?php echo $form->textField($model,'username',array('size'=>45,'maxlength'=>45)); ?>
			<?php echo $form->error($model,'username'); ?>
		</div>

		<div class="row">
			<?php echo $form->labelEx($model,'password'); ?>
			<?php echo $form->passwordField($model,'password',array('size'=>45,'maxlength'=>45)); ?>
			<?php echo $form->error($model,'password'); ?>
		</div>

		<div class="row">
			<?php echo $form->labelEx($model,'roles'); ?>
			<?php echo $form->dropDownList($model, 'roles', $model->getRoles(),
				array('prompt' => 'Select a Role')
				); ?>
				<?php echo $form->error($model,'roles'); ?>
			</div>


			<div class="row">
				<?php echo $form->labelEx($model,'first_name'); ?>
				<?php echo $form->textField($model,'first_name',array('size'=>45,'maxlength'=>45)); ?>
				<?php echo $form->error($model,'first_name'); ?>
			</div>

			<div class="row">
				<?php echo $form->labelEx($model,'last_name'); ?>
				<?php echo $form->textField($model,'last_name',array('size'=>45,'maxlength'=>45)); ?>
				<?php echo $form->error($model,'last_name'); ?>
			</div>

			<div class="row">
				<?php echo $form->labelEx($model,'e_mail'); ?>
				<?php echo $form->textField($model,'e_mail',array('size'=>45,'maxlength'=>45)); ?>
				<?php echo $form->error($model,'e_mail'); ?>
			</div>


			<div class="row">
				<?php echo $form->labelEx($model,'branches_id'); ?>
				<?php echo $form->dropDownList($model, 'branches_id', CHtml::listData(
					Branches::model()->findAll(), 'id', 'branch_name'),
				array('prompt' => 'Select a branch')
				); ?>
				<?php echo $form->error($model,'branches_id'); ?>
			</div>
			<?php if(is_null($model->id)) : ?>
				<?php if(CCaptcha::checkRequirements()): ?>
					<div class="row">
						<?php echo $form->labelEx($model,'verifyCode'); ?>
						<div>
							<?php $this->widget('CCaptcha'); ?>
							<?php echo $form->textField($model,'verifyCode'); ?>
						</div>
						<div class="hint">Please enter the letters as they are shown in the image above.
							<br/>Letters are not case-sensitive.</div>
							<?php echo $form->error($model,'verifyCode'); ?>
						</div>
					<?php endif; ?>
				<?php endif; ?>
				<?php if(!is_null($model->id)) :?>
					<div class="row">
						<?php echo $form->labelEx($model,'status'); ?>
						<?php echo $form->dropDownList($model,'status',array('active'=>'active','inactive'=>'inactive'),array('empty'=>'Select status')); ?>
						<?php echo $form->error($model,'status'); ?>
					</div>
				<?php endif; ?>

				<div class="row buttons">
					<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
				</div>

				<?php $this->endWidget(); ?>

</div><!-- form -->